package com.icoolkj.ms.auth.controller;

import com.icoolkj.ms.auth.service.IAuthAccountService;
import com.icoolkj.ms.common.core.response.ServerResponseEntity;
import com.icoolkj.ms.common.security.annotation.RequiresPermissions;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author icoolkj
 * @version 1.0
 * @description 认证账户管理控制器
 * @createDate 2025/02/04 16:33
 */
@RestController
@RequestMapping("/account")
@Tag(name = "认证账户管理", description = "认证账户管理相关接口")
public class AuthAccountController {

    @Autowired
    private IAuthAccountService authAccountService;

    /**
     * 根据用户ID逻辑删除账户
     *
     * @param uid 用户ID
     * @return 操作结果
     */
    @DeleteMapping("/{uid}")
    @Operation(summary = "根据用户ID逻辑删除账户", description = "根据用户ID逻辑删除账户")
    @RequiresPermissions("auth:account:delete")
    public ServerResponseEntity<Integer> deleteByUid(
            @Parameter(description = "用户ID", required = true) @PathVariable Long uid) {
        int rows = authAccountService.deleteByUid(uid);
        return rows > 0 ? ServerResponseEntity.success(rows) : ServerResponseEntity.fail("删除失败");
    }

    /**
     * 批量逻辑删除账户
     *
     * @param uids 用户ID数组
     * @return 操作结果
     */
    @DeleteMapping("/batch")
    @Operation(summary = "批量逻辑删除账户", description = "批量逻辑删除账户")
    @RequiresPermissions("auth:account:delete")
    public ServerResponseEntity<Integer> batchDeleteByUids(
            @Parameter(description = "用户ID数组", required = true) @RequestBody Long[] uids) {
        int rows = authAccountService.batchDeleteByUids(uids);
        return rows > 0 ? ServerResponseEntity.success(rows) : ServerResponseEntity.fail("批量删除失败");
    }
} 